package struts.actionForm.entreprise;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

public class BeanInscriptionEntreprise extends ActionForm 
{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private String login=null;
	private String mdp=null;
	private String conf_mdp=null;
	public String getLogin()
	{
		return login;
	}
	
	public void setLogin(String login) 
	{
		this.login = login;
	}
	
	public String getMdp() 
	{
		return mdp;
	}
	
	public void setMdp(String mdp) 
	{
		this.mdp = mdp;
	}
	
	public String getConf_mdp() 
	{
		return conf_mdp;
	}
	
	public void setConf_mdp(String conf_mdp) 
	{
		this.conf_mdp = conf_mdp;
	}
	
	@Override
	public ActionErrors validate(ActionMapping mapping,	HttpServletRequest request)
	{
		request.getSession().setAttribute("message_inscription", null);
		
		ActionErrors erreurs =new ActionErrors();
		if((getLogin()=="")||(getLogin()==null))
		{
			erreurs.add("login_vide", new ActionMessage("InscriptionEntreprise.erreur.loginRequis"));
		}
		if(((getMdp()=="")||(getMdp()==null)||(getMdp().length()<8)))
		{
			erreurs.add("mo_de_passe_invalide", new ActionMessage("InscriptionEntreprise.erreur.mdpRequis"));
		}
		else
		{
			if(!(getMdp().equals(getConf_mdp())))
				erreurs.add("mot_de_passes_different", new ActionMessage("InscriptionEntreprise.erreur.mdpdif"));
		}
		
		return erreurs;
	}
}
